package com.lyl.mysqlmonitor.callback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 默认的索引分析回调实现
 * 可作为示例或基类使用
 */
public class DefaultIndexAnalysisCallback implements IndexAnalysisCallback {

    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultIndexAnalysisCallback.class);

    @Override
    public void onAnalysisStart(String sql) {
        LOGGER.info("--> 开始分析SQL: {}", sql);
    }

    @Override
    public void onAnalysisComplete(String sql, String analysisResult, boolean isJson) {
        if (isJson) {
            LOGGER.info("--> SQL分析完成，JSON结果: {}", analysisResult);
        } else {
            LOGGER.info("--> SQL分析完成，详细报告: \n{}", analysisResult);
        }
    }

    @Override
    public void onAnalysisError(String sql, String errorMessage, Throwable exception) {
        LOGGER.error("--> SQL分析出错: {}, 原因: {}", sql, errorMessage, exception);
    }
}
